#include "EasyMsgEventHandler.h"
#include "EasyMsgDispatcher.h"
namespace EasyMsgImp{

MsgArrivedEvent::MsgArrivedEvent(EM::EasyMsg *msg):
    QEvent((QEvent::Type)(QEvent::User+MsgArrivedEventType))
{
    this->msg = msg;
}

EasyMsgEventHandler::EasyMsgEventHandler(QObject *parent) : QObject(parent)
{

}

void EasyMsgEventHandler::customEvent(QEvent *event)
{
    if(event->type() == (QEvent::Type)(QEvent::User+MsgArrivedEventType)){
        EasyMsgDispatcher::Instance()->dispatch(static_cast<MsgArrivedEvent*>(event)->msg);
    }
}

}

